﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace tools.dic
{
    public partial class keep : Form
    {
        public keep()
        {
            InitializeComponent();
        }

        private void btn_keep_Click(object sender, EventArgs e)
        {


            try
            {
                DirectoryInfo di = new DirectoryInfo(@txt_url.Text);
                FindFile(di);
                MessageBox.Show("ok");
            }
            catch (Exception)
            {
                MessageBox.Show("error");
            }


        }


        void FindFile(DirectoryInfo di)
        {

            DirectoryInfo[] dis = di.GetDirectories();
            for (int j = 0; j < dis.Length; j++)
            {
                //Console.WriteLine("目录：" + dis[j].FullName);
                if (dis[j].FullName.IndexOf(".svn") == -1)
                {
                    // txt_url.Text = txt_url.Text + "," + dis[j].FullName;
                    DirectoryInfo fdi = new DirectoryInfo(@dis[j].FullName);
                    if (fdi.GetFiles().Length + fdi.GetDirectories().Length == 0)
                    {
                        //目录为空
                        TextWriter tw = new StreamWriter(@dis[j].FullName + "\\.keep");
                        tw.WriteLine("tt");
                        tw.Close();
                    }
                    FindFile(dis[j]);
                }

            }
        }



    }
}
